package com.jeff.android.lab.commonlib;

import android.content.Context;

import com.jeff.android.lab.commonlib.impl.EmptyHomeService;
import com.jeff.android.lab.commonlib.impl.EmptyLoginService;
import com.jeff.android.lab.commonlib.service.IHomeService;
import com.jeff.android.lab.commonlib.service.ILoginService;

/**
 * @author: duff
 * @date: 2019/2/25
 * @since: 1.0.0
 */
public class ServiceFactory {

    private static ServiceFactory sInstance;

    private ILoginService mLoginService;
    private IHomeService mHomeService;

    public static ServiceFactory getInstance() {
        if (sInstance == null) {
            sInstance = new ServiceFactory();
        }

        return sInstance;
    }

    public void setLoginService(ILoginService loginService) {
        this.mLoginService = loginService;
    }

    public ILoginService getLoginService() {
        if (mLoginService == null)
            mLoginService = new EmptyLoginService();
        return mLoginService;
    }

    public void setHomeService(IHomeService homeService) {
        this.mHomeService = homeService;
    }

    public IHomeService getHomeService() {
        if (mHomeService == null)
            mHomeService = new EmptyHomeService();
        return mHomeService;
    }

    public void launchLogin(Context context) {
        getLoginService().launch(context, "");
    }

    public void launchHome(Context context) {
        getHomeService().launch(context, "");
    }

}
